/**
 * @author chentl
 * @version V1.0
 * @Project leisurely
 * @Title TimeServerHandlerExecutePool.java
 * @Description 服务端 处理类线程池
 * @Package com.echo.ioex.wio.server.pool
 * @date 2020/9/18 12:46 下午
 * @Copyright: 陈泰来の学习档案 .
 */
package com.echo.ioex.wio.server.pool;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Slf4j
public class TimeServerHandlerExecutePool {

    private ExecutorService executor;


    /**
    * @author chentl
    * @description 构造有界线程池、有界阻塞队列 初始化线程池执行者
    * @date 2020/9/18 12:55 下午
    * @params [maxPoolSize, queueSize]
    * @return
    */
    public TimeServerHandlerExecutePool(int maxPoolSize, int queueSize) {
        executor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), maxPoolSize, 120L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(queueSize));
    }


    public void execute(Runnable task) {
        executor.execute(task);
    }

}
